/**
* Created with CLion.
* User:Lenovo
* Date:2023-05-24
* Time:17:05
* Description:洛谷 P4017  最大食物链计数
*/

#include <stdio.h>

int mod = 80112002;

typedef struct Edge
{
    int to;
    int next;
} Edge;

void Init(Edge *edge, int m)
{
    for (int i = 0; i < m; i++)
    {
        edge[i].next = -1;
        edge[i].to = -1;
    }
}

void add(Edge *edge, int u, int v, int count, int *head)
{
    edge -> to = v;
    edge -> next = head[u];
    head[u] = count;
}

int dfs(int num, Edge *edge, int *head, int *out, int *Sum)
{
    if (!out[num])
    {
        return 1;
    }
    if (Sum[num]) // 记忆化搜索
    {
        return Sum[num];
    }

    int sum = 0;
    for (int i = head[num]; i != -1; i = edge[i].next) // 基于链式前向星的 DFS
    {
        sum = (sum + dfs(edge[i].to, edge, head, out, Sum)) % mod;
    }
    Sum[num] = sum % mod;
    return Sum[num];
}

int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    Edge edge[m];
    int head[n];
    int in[n];// 入度
    int out[n];// 出度
    int Sum[n];

    for (int i = 0; i < n; i++)
    {
        head[i] = -1;
        in[i] = 0;
        out[i] = 0;
        Sum[i] = 0;
    }
    long long ans = 0;

    Init(edge, m);

    for (int i = 0; i < m; i++)
    {
        int u, v;
        scanf("%d %d", &u, &v);
        in[v - 1]++;
        out[u - 1]++;
        add(&edge[i], u - 1, v - 1, i, head);
    }

    for (int i = 0; i < n; i++)
    {
        if (in[i] == 0)
        {
            ans += dfs(i, edge, head, out, Sum) % mod;
        }
    }
    printf("%lld", ans % mod);

    return 0;
}
